package com.parktech.sun.domain.model.unionnews;

import com.parktech.sun.domain.model.BaseEntity;
import com.parktech.sun.domain.model.ContentEntity;

import javax.persistence.*;
import java.util.List;

/**
 * User: Think
 * Date: 11-1-20
 * Time: 下午9:08
 */
@Entity
public class UnionNewsGroup extends BaseEntity {

    private String name;

    private UnionNews unionNews;

    private Integer orderCode;

    private List<ContentEntity> contentEntityList;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(Integer orderCode) {
        this.orderCode = orderCode;
    }

    @ManyToOne
    public UnionNews getUnionNews() {
        return unionNews;
    }

    public void setUnionNews(UnionNews unionNews) {
        this.unionNews = unionNews;
    }

    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
    @JoinTable(name = "SO_UNIONNEWSGROUP_CONTENTENTITY_REF",
            joinColumns = {@JoinColumn(name = "union_news_group_id", referencedColumnName = "ID", table = "SO_union_news_gropu")},
            inverseJoinColumns = {@JoinColumn(name = "content_entity_id", referencedColumnName = "id", table = "SO_CONTENT_ENTITY")})
    public List<ContentEntity> getContentEntityList() {
        return contentEntityList;
    }

    public void setContentEntityList(List<ContentEntity> contentEntityList) {
        this.contentEntityList = contentEntityList;
    }
}
